package pct.database;

import java.util.LinkedList;

import pct.entity.Group;
import pct.entity.Post;
import pct.entity.Topic;
import pct.entity.User;
import pct.group.ApplyMessage;
import pct.post.ReportMessage;

/*
 * PcServiceInterface
 * Supply data access operation interface
 */
public interface PcServiceInterface {
	/*
	 * userExists
	 * check whether the username has been already registered
	 */
	public boolean userExists ( User user );
	/*
	 * addUser
	 * add a new User instance into database
	 */
	public void addUser( User user );
	/*
	 * authenticateUser
	 * check whether matches the username & password in database
	 * if match, return the user instance, else return null
	 */
	public User authenticateUser(User user );
	/*
	 * getRelatedGroups
	 * get all groups User joins from database
	 */
	public LinkedList<Group> getAllRelatedGroups(User user);
	/*
	 * getTargetedRelatedGroups
	 * filter the rows from all related groups
	 */
	public LinkedList<Group> getTargetedRelatedGroups(User user, int startRow, int endRow);
	/*
	 * getMoreGroups
	 * get all groups in database except for those the User has joined
	 */
	public LinkedList<Group> getMoreGroups(User user);
	/*
	 * getGroupRows
	 * get row number of all related groups
	 */
	public int getGroupRows(User user);
	public int getTopicRows(String groupName);
	
	/*
	 * getRelatedTopics
	 * get all topics under the given group
	 */
	public LinkedList<Topic> getRelatedTopics(String groupname);
	
	public LinkedList<Topic> getTargetedTopics(String groupname, int startRow, int endRow);
	/*
	 * authenticateQuestion
	 * check if the user give the right question and answer
	 * if right, return user's password, else return null
	 */
	public String authenticateQuestion(User user);
	/*
	 * groupExists
	 * check if group already exits in the database
	 */
	public boolean groupExists(Group group);
	/*
	 * addGroup
	 * add a new group in the database
	 * this operation can only done by Administrator
	 */
	public void addGroup(Group group);
	/*
	 * applyNewGroup
	 * apply for a new group, waiting for approval from Administrator
	 */
	public void applyNewGoup(Group group, User user);
	/*
	 * 
	 */
	public void reportPost(Post post, User user);
	/*
	 * getToDoList_group
	 * get all the unhandled group apply
	 */
	public LinkedList<ApplyMessage> getToDoList_group();
	/*
	 * getToDoList_report
	 * get all the unhandled report
	 */
	public LinkedList<ReportMessage> getToDoList_report();
	/*
	 * getMatchedTopics
	 * get all matched topics
	 */
	public LinkedList<Topic> getMatchedTopics(String title, int startRow, int endRow);
	/*
	 * getTargetedMatchedTopics
	 * get all targeted matched topics from startRow to endRow
	 */
	public LinkedList<Topic> getTargetedMatchedTopics(String title, int startRow, int endRow);
	/*
	 * getMatchedGroups
	 * get all matched groups
	 */
	public LinkedList<Group> getMatchedGroups(String title, int startRow, int endRow);
	/*
	 * getTargetedMatchedGroups
	 * get all targeted matched groups from startRow to endRow
	 */
	public LinkedList<Group> getTargetedMatchedGroups(String title, int startRow, int endRow);
	/*
	 * getMatchedPosts
	 * get all matched posts
	 */
	public LinkedList<Post> getMatchedPosts(String content,int startRow, int endRow);
	/*
	 * getTargetedMatchedPosts
	 * get all targeted matched posts from startRow to endRow
	 */
	public LinkedList<Post> getTargetedMatchedPosts(String content, int startRow, int endRow);
	/*
	 * 
	 */
	public void acceptGroupApplication(ApplyMessage msg);
	/*
	 * 
	 */
	public void rejectGroupApplication(ApplyMessage msg);
	/*
	 * 
	 */
	public boolean groupExists(ApplyMessage msg);
	public void joinGroup(String username, String groupname);
	
	public boolean isJoined(String username, String gorupname);
}
